package com.atguigu.gmall.task;

import com.atguigu.gmall.constant.MqConst;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@EnableScheduling
@Component
public class ScheduledJob {
    @Autowired
    private RabbitTemplate rabbitTemplate;
    //https://cron.qqe2.com/
    // 分，时，日，月，周，年
    @Scheduled(cron = "0 0 1 * * ?")
    public void task1() {
        // 发送的消息
        rabbitTemplate.convertAndSend(MqConst.SCAN_SECKILL_EXCHANGE,  MqConst.SCAN_SECKILL_ROUTE_KEY, "");
        System.out.println("开始干活啦！");
    }
    // 分，时，日，月，周，年
    @Scheduled(cron = "0 0 5 * * ?")
    public void task18() {
        rabbitTemplate.convertAndSend(MqConst.CLEAR_REDIS_EXCHANGE,  MqConst.CLEAR_REDIS_ROUTE_KEY, "");
    }
}
